# !/usr/bin/python3
# -*- coding: utf-8 -*-
# ------------------------------------------
# @Time    : Date - 2021/8/30   Time - 20:44
# @Author  : Spence Guo Tang
# @FileName: bishi_t4.py
# ------------------------------------------

from typing import List


class Solution:
    def func(self, grid: List[List[int]]) -> List:
        result = []
        row = len(grid)
        col = len(grid[0])

        for r in range(row):
            for c in range(col):
                if grid[r][c] == 0:
                    grid[r][c] = 1
                    a = max(self.heng(grid, r, c), self.shu(grid, r, c), self.xie(grid, r, c))
                    grid[r][c] = 0
                    if a == 5:
                        result.append([r, c])
        return result

    def heng(self, grid: List[List[int]], r: int, c: int) -> int:
        if not self.inArea(grid, r, c):
            return 0
        if grid[r][c] != 1:
            return 0
        grid[r][c] = 2
        return 1 + self.heng(grid, r, c - 1) + self.heng(grid, r, c + 1)

    def shu(self, grid: List[List[int]], r: int, c: int) -> int:
        if not self.inArea(grid, r, c):
            return 0
        if grid[r][c] != 1:
            return 0
        grid[r][c] = 2
        return 1 + self.shu(grid, r - 1, c) + self.shu(grid, r + 1, c)

    def xie(self, grid: List[List[int]], r: int, c: int) -> int:
        if not self.inArea(grid, r, c):
            return 0
        if grid[r][c] != 1:
            return 0
        grid[r][c] = 2
        return 1 + self.xie(grid, r - 1, c - 1) + self.xie(grid, r + 1, c + 1)

    def inArea(self, grid: List[List[int]], r: int, c: int) -> bool:
        row = len(grid)
        col = len(grid[0])
        return 0 <= r < row and 0 <= c < col


if __name__ == '__main__':
    # n = int(sys.stdin.readline().strip())
    # chess = []
    # for _ in range(n):
    #     line = sys.stdin.readline().strip()
    #     line = list(map(int, line.split(" ")))
    #     chess.append(line)
    chess = [
        [0, 0, 0, 0, 0, 0],
        [0, 1, 0, 0, 0, 0],
        [0, 0, 1, 0, 0, 0],
        [0, 0, 0, 1, 0, 0],
        [0, 0, 0, 0, 1, 0],
        [0, 0, 0, 0, 0, 0],
    ]
    s = Solution()
    result = s.func(chess)
    for r in result:
        print(' '.join([str(x + 1) for x in r]))
